﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace katOS
{
    abstract class AbstractQueue<G>: InterfaceQueue<G>
    {
        protected LinkedList<G> list = new LinkedList<G>();
        protected G lastone_in;
        private int exec_time=0;

        protected int id;
        protected String name;
        protected String type;
        protected int quantum;
        protected bool preemptive;
        protected int queueOnQuantumEnd;
        protected int queueOnIOEnd;
        protected int queue_number;

        public abstract void addProcess(G new_process);
        public abstract G getElement(int i);
        public abstract G getLastProcess();

        public G Peek()
        {
            if (!(list.Count==0))
            {
                //Console.WriteLine("the list was not empty");
                return list.First();
            }
            //Console.WriteLine("is returning null or something");
            return default(G);
        }

        public G removeFirst()
        {
            if (!(list.Count == 0))
            {
                G temp = list.First();
                list.Remove(list.ElementAt(0));
                return temp;
            }
            return default(G);
        }

       
        public bool isEmpty()
        {
            if (list.Count == 0)
            {
                return true;
            }
            return false;
        }

     
        public void Remove(G p)
        {
            list.Remove(p);
        }

       
        public LinkedList<G> getQueue()
        {
            return list;
        }

       
        public abstract G getFirst();
        /*{
            Console.WriteLine("el tamaño de la estupida lista! "+list.Count);
              if(list.Count>0)
                return list.ElementAt(0);
          return default G;
          return list.First();
        }*/

        
        public int getQuantum()
        {
            return quantum;
        }

        public void setQuantum(int quantum)
        {
            this.quantum = quantum;
        }


        public bool getPreemptive()
        {
            return this.preemptive;
        }

        public void setPreemptive(bool preemptive)
        {
            this.preemptive = preemptive;
        }

        public int getQueueOnQuantumEnd()
        {
            return queueOnQuantumEnd;
        }

        public void setQueueOnQuantumEnd(int queueOnQuantumEnd)
        {
            this.queueOnQuantumEnd = queueOnQuantumEnd;
        }

        public int getQueueOnIOEnd()
        {
            return queueOnIOEnd;
        }

        public void setQueueOnIOEnd(int queueOnIOEnd)
        {
            this.queueOnIOEnd = queueOnIOEnd;
        }

        public int getId()
        {
            return id;
        }

        public void setId(int id)
        {
            this.id = id;
        }

        public String getName()
        {
            return name;
        }

        public void setName(String name)
        {
            this.name = name;
        }

        public String getType()
        {
            return type;
        }

        public void setType(String type)
        {
            this.type = type;
        }

        public int getQueueNumber()
        {
            return queue_number;
        }

        public void setQueueNumber(int queue_num)
        {
            queue_number = queue_num;
        }

        public void addExecTime()
        {
            exec_time++;
        }

        public int getExecTime()
        {
            return exec_time;
        }
    }
}
